package com.tiantai.dashboard.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tiantai.common.annotation.Log;
import com.tiantai.common.core.controller.BaseController;
import com.tiantai.common.core.domain.AjaxResult;
import com.tiantai.common.enums.BusinessType;
import com.tiantai.dashboard.domain.TeaMarker;
import com.tiantai.dashboard.service.ITeaMarkerService;
import com.tiantai.common.utils.poi.ExcelUtil;
import com.tiantai.common.core.page.TableDataInfo;

/**
 * 标记管理Controller
 * 
 * @author handsomedog
 * @date 2024-07-25
 */
@RestController
@RequestMapping("/dashboard/marker")
public class TeaMarkerController extends BaseController
{
    @Autowired
    private ITeaMarkerService teaMarkerService;

    /**
     * 查询标记管理列表
     */
    //@PreAuthorize("@ss.hasPermi('dashboard:map:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeaMarker teaMarker)
    {
        startPage();
        List<TeaMarker> list = teaMarkerService.selectTeaMarkerList(teaMarker);
        return getDataTable(list);
    }

    /**
     * 导出标记管理列表
     */
    @PreAuthorize("@ss.hasPermi('dashboard:map:export')")
    @Log(title = "标记管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeaMarker teaMarker)
    {
        List<TeaMarker> list = teaMarkerService.selectTeaMarkerList(teaMarker);
        ExcelUtil<TeaMarker> util = new ExcelUtil<TeaMarker>(TeaMarker.class);
        util.exportExcel(response, list, "标记管理数据");
    }

    /**
     * 获取标记管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dashboard:map:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(teaMarkerService.selectTeaMarkerById(id));
    }

    /**
     * 新增标记管理
     */
    @PreAuthorize("@ss.hasPermi('dashboard:map:add')")
    @Log(title = "标记管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeaMarker teaMarker)
    {
        return toAjax(teaMarkerService.insertTeaMarker(teaMarker));
    }

    /**
     * 修改标记管理
     */
    @PreAuthorize("@ss.hasPermi('dashboard:map:edit')")
    @Log(title = "标记管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeaMarker teaMarker)
    {
        return toAjax(teaMarkerService.updateTeaMarker(teaMarker));
    }

    /**
     * 删除标记管理
     */
    @PreAuthorize("@ss.hasPermi('dashboard:map:remove')")
    @Log(title = "标记管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teaMarkerService.deleteTeaMarkerByIds(ids));
    }
}
